<?php echo form_open('admin/dataman/connection_update',' id="connection" class="connection" ');?>

	<h3><?php //echo lang('dataman.categories_list'); ?></h3>
	
	<div id="action"><?php $this->load->view('admin/partials/buttons', array('buttons' => array('save_connection'))); ?></div>
	
	<table border="0" class="table-list">
		 <?php 
			$options = array();
			$options[0] = '';
			foreach ( $option  as $obj ){
				$options[$obj->id] = stripslashes( $obj->name );
			}
		?>
		<tbody>
			<thead>
				<th><?php echo lang('dataman.field')?></th>
				<th><?php echo lang('dataman.name')?></th>
			</thead>
			<tr>
				<td><?php echo form_label( lang('dataman.connection.UpperContentID') ); ?></td>
				<td><?php echo form_dropdown('upper_content_id',$options,array($connect->upper_content_id),' id="upper_content_id"'); ?></td>
			</tr>
			<tr>
				<td><?php echo form_label( lang('dataman.connection.LowerContentID') ); ?></td>
				<td><?php echo form_dropdown('lower_content_id',$options,array($connect->lower_content_id),' id="lower_content_id"'); ?></td>
			</tr>
			<?php if($connect->id > 0):?>
			<tr>
				<td><?php echo form_label( lang('dataman.connection.NumberofPosts') ); ?></td>
				<td><?php echo form_input('weight',$connect->weight,'maxlength="100" size="50" '); ?></td> <!-- disabled="disabled" -->
			</tr>
			<?php endif;?>
			<?php echo form_hidden('id',$connect->id); ?>
		</tbody>
	</table>
	
<?php echo form_close(); ?>

<script type="text/javascript">
	function checkB4Submit(){
		$upper = jQuery('#upper_content_id').val();
		$lower = jQuery('#lower_content_id').val();
		$id = jQuery('input[name="id"]').val();
		
		if($upper*$lower == 0 || $upper== $lower){
			alert("Upper Content And Lower Content are not validated.");
			return false;
		}

		if(jQuery('input[name="weight"]').val()== 0 && $id > 0){
			alert("Number of Posts is not validated");
			return false;
		}
		
		jQuery('#connection').submit();
	}
</script>